// table切换
function tab(){
    let $tab = $(".container");
    $tab.find(".ovfs-item").click(function(){
        let index = $(this).index();
        $(this).addClass("active").siblings().removeClass("active")
        $tab.find(".bl-tab-container-item").eq(index).show().siblings().hide()

    })
}
tab();
//回到顶部
$('.jt').on('click', function () {
    $(window).scroll();
    $('html').animate({ scrollTop: 0 });
});
//滚动加载
function scrollLoad() {
    var page = 1;
    $.ajax({
        url: '../php/getQqgdata.php',
        type: 'get',
        dataType: 'json',
        data: {
            page: page
        },
        success: function (data) {
            console.log(data)
            if (data.code == 1) {
                var html = ""
                data.list.forEach(item => {
                    html += `
                    <li>
                    <div class="white-bg"><a href="javascript:;">
                            <div class="lazy-box"><img
                                    src="${item.url}"
                                    alt="" class="lazy"></div>
                            <div class="sp-text">${item.desc}</div>
                            <div class="sp-price"><i class="small-rmb">¥</i>${item.price}</div>
                        </a></div>
                </li>
                        `
                });
                $(".sp-region .floor-half ul").html(html);
            }
        }
    })
    var flag = true;
    $(window).scroll(function () {
        var scrollTop = $(window).scrollTop();
        var winHeight = $(window).height();
        var pageHeight = $("html").height();
        if (flag) {
            if (scrollTop + winHeight >= pageHeight-100){
                flag=false;
                page++;
                $.ajax({
                    url: '../php/getQqgdata.php',
                    type: 'get',
                    dataType: 'json',
                    data: {
                        page: page
                    },
                    success: function (data) {
                        console.log(data)
                        if (data.code == 1) {
                            var html = ""
                            data.list.forEach(item => {
                                html += `
                                <li>
                                <div class="white-bg"><a href="javascript:;">
                                        <div class="lazy-box"><img
                                                src="${item.url}"
                                                alt="" class="lazy"></div>
                                        <div class="sp-text">"${item.desc}"</div>
                                        <div class="sp-price"><i class="small-rmb">¥</i>"${item.price}"</div>
                                    </a></div>
                            </li>
                                    `
                            });
                            $(".sp-region .floor-half ul").append(html);
                        }
                    }
                })
            }
        }
    })
}
scrollLoad();